package com.itheima.dao;

import com.itheima.domain.Account;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface Accountdao {

    /**
     * 查询所有账户，并且获取每个账户所属的用户信息
     * @return
     * property表示实体类中的属性名称
     * column表示实体类属性相对应的数据库表字段名称
     * one表示多对一(一对一)的级联关系配置
     * one=@One(select="com.itheima.dao.IUserDao.findById",关联查询IUserDao接口中的findById得
    方法
    fetchType= FetchType.EAGER)表示立即加载
     */
/*

    @Select("select * from account")
    @Results(value = {
            @Result(id=true,column = "id" ,property = "id"),
            @Result(column = "uid" ,property = "uid"),
            @Result(column = "money" ,property = "money"),
            @Result(column = "uid",property ="user",
                    one = @One(select ="com.itheima.dao.Userdao.findById" ,fetchType = FetchType.EAGER))

    })
      List<Account> findall();
*/


    @Select("select * from account where uid=#{userId}")
    List<Account> findone(int one);
}
